//
//  RABookrackRecommendCell.m
//  ReadApp
//
//  Created by 飞猪 on 2018/11/8.
//  Copyright © 2018年 Facebook. All rights reserved.
//

#import "RABookrackRecommendCell.h"

@interface RABookrackRecommendCell ()

@property (nonatomic, strong) UIView *bgV;
@end

@implementation RABookrackRecommendCell

- (void)createViews {
  self.backgroundColor = kNavColor; 
  
  [self.contentView addSubview:self.titleImg];
  CGFloat w = (kScreenWidth - 4 * 10.f) / 3;
  [self.titleImg mas_makeConstraints:^(MASConstraintMaker *make) {
    make.centerY.mas_equalTo(0);
    make.centerX.mas_equalTo(0);
    make.size.mas_equalTo(CGSizeMake(w, w * 1.3));
  }];
  
  [self.contentView insertSubview:self.bgV atIndex:0];
  [self.bgV mas_makeConstraints:^(MASConstraintMaker *make) {
    make.edges.mas_equalTo(UIEdgeInsetsMake(0, -1, 0, -1));
  }];
  
}

- (void)setModel:(RABookFaceModel *)model {
  [super setModel:model];
  
  if (model.place == 0) {
    [self.titleImg mas_updateConstraints:^(MASConstraintMaker *make) {
      make.centerX.mas_equalTo(0).mas_offset(3.4);
    }];
  }
  else if (model.place == 1) {
    [self.titleImg mas_updateConstraints:^(MASConstraintMaker *make) {
      make.centerX.mas_equalTo(0);
    }];
  }
  else {
    [self.titleImg mas_updateConstraints:^(MASConstraintMaker *make) {
      make.centerX.mas_equalTo(0).mas_offset(-3.4);
    }];
  }
  
}

- (UIView *)bgV {
  if (!_bgV) {
    _bgV = [UIView new];
    _bgV.backgroundColor = kNavColor;
  }
  return _bgV;
}

@end
